<?php
/**
 * author      :chenwenwen
 * createTime  :2020-04-05 22:35
 * description :
 */

namespace app\demo\exception;

use think\exception\Handle;
use think\Response;
use Throwable;

class Http extends Handle {
    public $httpStatus = 500;
    public function render($request, Throwable $e): Response {
        // 添加自定义异常处理机制
        if(method_exists($e,'getStatusCode')) {
            $httpStatus = $e->getStatusCode();
        } else {
            $httpStatus = $this->httpStatus;
        }
        return show(config('status.error'), $e->getMessage(),[],$httpStatus);
    }
}